package com.janal.controller.Postbar.bar;

import com.janal.model.Postbar.bar.Post_bar;
import com.janal.service.Postbar.bar.BarService;
import com.janal.service.Postbar.bar.BarServiceImpl;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author Lenovo
 */
public class AdminCheckBarServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1、调用service获取申请创建的贴吧
        BarService bs = new BarServiceImpl();
        List<Post_bar> pb = bs.getAllBarMessage();
        //2、转化成json格式的字符串
        JSONArray pbjsonArray =JSONArray.fromObject(pb);
        //3、响应给客户端
        resp.getWriter().print(pbjsonArray);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
